import {repairItemPage as getMixinList} from "@/api/repair/item";
import {getDict} from "@/api/common";

export const mixinDialog = {
  data() {
    return {
      mixinDialogVisible: false, //表格弹框隐藏显示
      getMixinList, // 获取弹框数据接口
      hasMixinFooter: true, // 是否需要底部按钮默认true
      mixinSearchDialog: {
        inline: true,
        formDesc: {
          repairProf: {
            type: "select",
            label: '工种',
            prop: {
              text: "description",
              value: "value"
            },
            // Promise 对象
            options: async (data) => {
              const list = await getDict("work_type")
              return list.data.result
            }
          },
          repairCateFir: {
            type: "input",
            label: '一级分类',
          },
          repairCateSec: {
            type: "input",
            label: '二级分类',
          },
          repairItem: {
            type: "input",
            label: '维修项目',
          },
          isBase: {
            label: "基础整备项",
            type: "select",
            options: [
              { text: "是", value: "Y" },
              { text: "否", value: "N" }
            ]
          }
        },
      },
      mixinDialogColumn: [
        {
          type: "selection",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
        },
        {
          prop: "repairProf",
          label: '工种',
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getDict("work_type")
            return list.data.result;
          },
          showOverflowTooltip: true,
        },
        {
          prop: 'repairCateFir',
          label: '一级分类',
          showOverflowTooltip: true
        },
        {
          prop: 'repairCateSec',
          label: '二级分类',
          showOverflowTooltip: true
        },
        {
          prop: 'repairItem',
          label: '维修项目',
          showOverflowTooltip: true
        },
        {
          prop: 'repairHours',
          label: '工时',
          showOverflowTooltip: true
        },
        {
          prop: 'repairHoursUnitPrice',
          label: '工时单价',
          showOverflowTooltip: true
        },
        {
          prop: 'repairHoursTotalPrice',
          label: '工时总价',
          showOverflowTooltip: true
        },
        {
          prop: 'isBase',
          label: '基础整备项',
          showOverflowTooltip: true,
          render: (h, scope) => {
            const qmiTestStep = { 'Y': '是', 'N': '否' }
            return (
              <span>{qmiTestStep[scope.row.isBase] || ''}</span>
            )
          }
        },
        {
          prop: 'isRepair',
          label: '使用物料',
          showOverflowTooltip: true,
          render: (h, scope) => {
            const qmiTestStep = { 'Y': '是', 'N': '否' }
            return (
              <span>{qmiTestStep[scope.row.isRepair] || ''}</span>
            )
          }
        },
        {
          prop: 'repairMaterialName',
          label: '使用物料名称',
          showOverflowTooltip: true,
        },
      ],
    };
  },
};
